﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sunny.UI;

namespace LEDVANCE.Oscilloscope.VirtualOscilloscope.DataGridViewHelper
{
    public class HideControlsWithTextHelper
    {
        public static void HideControlsWithText(Control parent, string textToHide)
        {
            // 遍历父控件的所有子控件
            foreach (Control control in parent.Controls)
            {
                // 检查控件的文本属性是否包含要隐藏的文本
                if (control is UISymbolButton button && button.Text.Contains(textToHide))
                {
                    button.Visible = false; // 隐藏控件
                }

                // 如果控件还有子控件，则递归调用该方法
                if (control.HasChildren)
                {
                    HideControlsWithText(control, textToHide);
                }
            }
        }
    }
}
